package org.litemall.netty.nettyDoman;

import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author Lizr
 * @Description 用戶socket链接信息
 * @CreateTime 2021-11-24 下午 5:27
 **/
public class UserChannel {
    /**
     * 管理员id
     */
    private Integer userId;
    /**
     * channel连接id
     */
    private String channelId;

    /**
     * socket 空闲次数 到达 3次后关闭 当前socket
     */
    private AtomicInteger readFreeCount;
    /**
     * channel连接
     */
    private io.netty.channel.Channel Channel;

    public Integer getUserId() {
        return userId;
    }
    public void sendTestMessage(String content){
        TextWebSocketFrame tws = new TextWebSocketFrame(content);
        this.getChannel().writeAndFlush(tws);
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getChannelId() {
        return channelId;
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public AtomicInteger getReadFreeCount() {
        return readFreeCount;
    }

    public void setReadFreeCount(AtomicInteger readFreeCount) {
        this.readFreeCount = readFreeCount;
    }

    public io.netty.channel.Channel getChannel() {
        return Channel;
    }

    public void setChannel(io.netty.channel.Channel channel) {
        Channel = channel;
    }
}
